package com.examples.keyboard;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class KeyboardBasic {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    Display display = new Display();
	    Shell shell = new Shell(display);
	    
	    Listener listener = new Listener() {
	        public void handleEvent(Event event) {
	            String string = event.type == SWT.KeyDown ? "DOWN ": "UP ";
	            string += event.type + " " + event.character + " " + event.keyCode;
	            System.out.println(string);
	        }
	    };
	    shell.addListener(SWT.KeyDown, listener);
	    shell.addListener(SWT.KeyUp, listener);
	    shell.setSize(200, 200);
	    shell.open();
	    while (!shell.isDisposed()) {
	        if (!display.readAndDispatch()) display.sleep();
	    }
	}

}
